
Partial Class search_result
    Inherits CustomPage

    Private _SearchFor As String
    Private _Busca As Busca

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim ResultDataTable As System.Data.DataTable
        Dim CountResults As Integer

        Try

            _SearchFor = Microsoft.Security.Application.AntiXss.HtmlEncode(Request.QueryString("Search"))

            If Not _SearchFor.Equals(String.Empty) Then

                _Busca = New Busca()

                ResultDataTable = _Busca.Search(_SearchFor)

                CountResults = ResultDataTable.Rows.Count

                Select Case CountResults
                    Case Is = 0
                        Me.ltrTitulo.Text = String.Concat("Nenhum resultado encontrado para '", _SearchFor, "'")
                    Case Is = 1
                        Me.ltrTitulo.Text = String.Concat(CountResults.ToString, " resultado encontrado para '", _SearchFor, "'")
                    Case Is > 1
                        Me.ltrTitulo.Text = String.Concat(CountResults.ToString, " resultados encontrados para '", _SearchFor, "'")
                End Select

                Me.rpBusca.DataSource = ResultDataTable
                Me.rpBusca.DataBind()

            End If

        Catch ex As Exception

        End Try

    End Sub

End Class
